package com.ysyx.ysyx_admin.service.impl;


import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ysyx.ysyx_admin.dto.BaseDto;
import com.ysyx.ysyx_admin.pojo.DriverPojo;
import com.ysyx.ysyx_admin.qo.DriverAuditQo;
import com.ysyx.ysyx_admin.service.DriverPojoService;
import com.ysyx.ysyx_admin.mapper.DriverPojoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Lenovo
 * @description 针对表【driver_inf(司机信息表)】的数据库操作Service实现
 * @createDate 2023-04-18 14:29:36
 */
@Service
public class DriverPojoServiceImpl
        implements DriverPojoService {

    @Autowired
    private DriverPojoMapper driverPojoMapper;

    //司机信息展示
    @Override
    public List<DriverPojo> showDriver(DriverPojo driverPojo) {
        List<DriverPojo> driverPojos = driverPojoMapper.showDriver(driverPojo);
        return driverPojos;
    }


    @Override
    public int driverCount() {
        int num = driverPojoMapper.driverCount();
        return num;
    }


    //司机审核信息展示
    @Override
    public List<DriverAuditQo> driverAudit(DriverAuditQo driverAuditQo) {
        List<DriverAuditQo> driverAuditQos = driverPojoMapper.driverAudit(driverAuditQo);
        return driverAuditQos;
    }

    @Override
    public int driverAuditCount() {
        int num = driverPojoMapper.driverAuditCount();
        return num;
    }


    //  通过审核
    @Override
    public BaseDto passAudit(DriverAuditQo driverAuditQo) {
        BaseDto baseDto = null;
//        UpdateWrapper<DriverAuditQo> updateWrapper = new UpdateWrapper<>();
//        updateWrapper.eq("driver_id", driverAuditQo.getDriverId())
//                .set("driver_passstate", 202);
//        List<DriverAuditQo> list = driverPojoMapper.passAudit(driverAuditQo, updateWrapper);
        int list = driverPojoMapper.passAudit(driverAuditQo);

        if (list > 0) {
            baseDto = new BaseDto(101, "成功通过", null, null);
            return baseDto;
        }
        baseDto = new BaseDto(102, "通过失败", null, null);
        return baseDto;
    }

    @Override
    public BaseDto noPassAudit(DriverAuditQo driverAuditQo) {
        BaseDto baseDto = null;
        int list = driverPojoMapper.noPassAudit(driverAuditQo);

        if (list > 0) {
            baseDto = new BaseDto(101, "成功通过", null, null);
            return baseDto;
        }
        baseDto = new BaseDto(102, "通过失败", null, null);
        return baseDto;
    }


}




